package com.sun;

import com.alibaba.excel.EasyExcel;
import com.sun.common.ExcelListener;
import com.sun.dto.DrugDto;
import com.sun.dto.ExcelStateDataVo;
import com.sun.service.CategoryService;
import com.sun.service.DrugService;
import com.sun.service.DrugSupplierService;
import com.sun.service.SupplierService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @Project: hospitalDrugInformationManagement
 * @Author: 86178
 * @Date: 2023/2/23 14:34
 * @FileName: testExcel
 * @Description: ""
 */
@SpringBootTest
@Slf4j
public class testExcel {

    @Autowired
    private DrugService drugService;

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private SupplierService supplierService;
    @Autowired
    private ExcelStateDataVo excelStateDataVo;
    @Autowired
    private DrugSupplierService drugSupplierService;

    /**
     * 简单的读取excel文件
     */
    @Test
    public void read() {
        String fileName = "E:\\qq\\2453352162\\filerecv\\demo2.xlsx";
        // 这里 需要指定读用哪个class去读，然后读取第一个sheet 文件流会自动关闭
        // 参数一：读取的excel文件路径
        // 参数二：读取sheet的一行，将参数封装在Drug实体类中
        // 参数三：读取每一行的时候会执行ExcelListener监听器
        EasyExcel.read(fileName, DrugDto.class, new ExcelListener(drugService, categoryService, supplierService, excelStateDataVo, drugSupplierService)).sheet().doRead();
    }



}
